package com.example.demo.Config;
//扩展springmvc

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Locale;

@Configuration
@EnableWebMvc //这玩意就是导入一个类DelegatingWebMvcConfiguration从容器中获取所有的webmvcconfig
public class MyMvcConfig implements WebMvcConfigurer {
    //    public interface ViewResolver 实现视图解析器的类我们就可以把它看作视图解析器
    @Bean
    public ViewResolver MyViewReslver(){
        return new MyViewReslver();
    }

    //    自定义类一个自己的视图解析器MyViewReslver
    public static class MyViewReslver implements ViewResolver {
        @Override
        public View resolveViewName(String viewName, Locale locale) throws Exception {
            return null;
        }
    }
//    视图跳转

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/yjh").setViewName("index");
    }
}
